<?php
class Department extends Zend_Db_Table{
    	protected $_name ="department";
	protected $_primary = 'id';

 //查询所有的department
   public function getAlldepartments($page,$perpage){
         $where = "1=1";
         $select = $this->select();
          $select->where($where);
          if($page!=""){
          $select->limitPage($page,$perpage);
          }
          $select->order('id desc');
          return $this->fetchAll($select)->toArray();
   }
   
//根据department_name 查询department
    public function getDepartmentBydepartment_name($department_name){
		$select = $this->select();
		$select->where("name='".$department_name."'");
		return $this->fetchAll($select)->toArray();
    }
    
   
   public function getAlldepartmentsexcel(){
         $where = "1=1";
         $select = $this->select();
          $select->where($where);
          $select->order('id asc');
          return $this->fetchAll($select)->toArray();
   }
     //根据id 查询teacher
    public function getdeparmentByid($id){
          $select = $this->select();
          $select->where("id=".$id);
          return $this->fetchAll($select)->toArray();
    }

 //更新teacher
    public function updatedepartmentByid($array,$id){

		$db = $this->getAdapter();
		$where=$db->quoteInto('id = ?', $id);
		$this->update($array, $where);
                return true;
	}
//删除teacher
     public function deldepartmentByid($id){
          $where = 'id = '. $id;
         $this->delete($where);
         return true;
    }
}
?>
